package cn.zd.demo1;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.PagerTabStrip;
import androidx.viewpager.widget.ViewPager;

import android.graphics.Color;
import android.os.Bundle;
import android.util.TypedValue;
import android.widget.Toast;

import cn.zd.demo1.adapter.MyFragmentAdapter;

public class FragmentActivity extends AppCompatActivity {

    private ViewPager vp_1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Toast.makeText(this,this.getClass().getName(),Toast.LENGTH_LONG).show();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fragment);
        // 翻页视图
        vp_1 = findViewById(R.id.vp_1);
        PagerAdapter adapter = new MyFragmentAdapter(getSupportFragmentManager());
        vp_1.setAdapter(adapter);
        vp_1.setCurrentItem(1);
        // 翻页标签栏
        PagerTabStrip pts_1 = findViewById(R.id.pts_1);
        pts_1.setTextSize(TypedValue.COMPLEX_UNIT_SP,20);
        pts_1.setTextColor(Color.GREEN);
    }
}